package com.caigou.bean.vo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Data
public class PrivilegeVO {

    /**
     * 权限Icon
     */
    private String privilegeIcon;

    /**
     * 权限code
     */
    private String privilegeCode;

    /**
     * 权限名称
     */
    private String privilegeName;

    /**
     * 父类权限code
     */
    @JsonIgnore
    private String parentPrivilegeCode;


    /**
     * 权限层级
     */
    private Integer privilegeLevel;

    private List<PrivilegeVO> childPrivilegeVos = new ArrayList<>();


    public String getPrivilegeCode() {
        if (!StringUtils.isEmpty(privilegeCode) && privilegeCode.length() == 9 && privilegeCode.startsWith("1130101")) {
            return privilegeCode.substring(privilegeCode.length() - 2);
        }
        return privilegeCode;
    }

    public void setPrivilegeCode(String privilegeCode) {
        this.privilegeCode = privilegeCode;
    }

    public PrivilegeVO() {
    }

    public PrivilegeVO(String privilegeCode, String privilegeName) {
        this.privilegeCode = privilegeCode;
        this.privilegeName = privilegeName;
    }


    public PrivilegeVO(String privilegeCode, String privilegeName, Integer privilegeLevel) {
        this.privilegeCode = privilegeCode;
        this.privilegeName = privilegeName;
        this.privilegeLevel = privilegeLevel;
    }

    public PrivilegeVO(String privilegeCode, String privilegeName, Integer privilegeLevel, String parentPrivilegeCode, String privilegeIcon) {
        this.privilegeCode = privilegeCode;
        this.privilegeName = privilegeName;
        this.parentPrivilegeCode = parentPrivilegeCode;
        this.privilegeLevel = privilegeLevel;
        this.privilegeIcon = privilegeIcon;
    }

    public PrivilegeVO(String privilegeCode, String privilegeName, Integer privilegeLevel, String parentPrivilegeCode) {
        this.privilegeCode = privilegeCode;
        this.privilegeName = privilegeName;
        this.parentPrivilegeCode = parentPrivilegeCode;
        this.privilegeLevel = privilegeLevel;
    }


}
